Compare files
You can view unsaved changes in the current file or all open files, as well as compare any two text files. They can be either versions of the same file or arbitrary files.
View unsaved changes
To view unsaved changes in the current file, go to Tools > Diff > Diff Current File.
To view unsaved changes in all open files, go to Tools > Diff > Diff Open Files.
Compare two files
To compare two files:
- Go to Tools > Diff > Diff External Files.
- Select two files to compare.
To compare the currently opened file against another file in a project or the file system:
- Open the first file in an editor.
- Right-click the second file in the Projects or File System view and select Diff Against Current File.
If Qt Creator cannot detect the encoding of the files to compare, a message displays the option to reload the document using some other encoding. For more information, see Change text encoding.
View changes

View the changes in the Edit mode. Color coding is used to mark changed lines. By default, red indicates lines that contain removed text (painted another shade of red) in the left pane and green indicates lines that contain added text (painted another shade of green) in the right pane.
To view the differences in a unified view where changed rows are placed below each other, select
(Switch to Unified Diff Editor).
To switch back to the side-by-side view, select
(Switch to Side by Side Diff Editor).
To only show text changes, select Ignore Whitespace.
To color changed lines evenly, without the other shade for the changed text within them, clear Character Changes.
To expand the context for the changes, set the number of unchanged lines to show in Context lines.
By default, the horizontal scroll bars in the left and right pane are synchronized. To use them independently of each other, select
(Synchronize Horizontal Scroll Bars).
Resolve merge conflicts
Git opens conflicted files from the commit window and Changes view in the internal merge editor by default. To use the merge tool configured in Git, disable Use internal merge tool in the Git preferences.
The merge editor shows the current and incoming versions above an editable result, which initially occupies about one quarter of the view. Use the inline buttons to choose the current version, incoming version, or both versions for a conflict. Review the result before saving. A border and matching conflict number identify the active conflict in all three panes. Scrolling synchronizes the centers of the panes, and resizing the panes keeps the active conflict centered.
Unchanged lines are initially hidden, keeping three lines of context around changes. Use Hide Unchanged Lines to toggle this behavior. Select a Show unchanged lines button to reveal a hidden section, or disable the toolbar action to reveal all unchanged lines.
For an integrated Git merge, select Edit as Text to continue in the normal text editor. Your partial resolutions remain unsaved changes; unresolved conflicts are shown with their original markers. Use Open in Merge Editor above the text editor or in the Git Current File menu to switch back, including your text edits.
Use Qt Creator as an external merge tool
Pass each merge input and the existing result file with its own option:
qtcreator -client -block -merge-base "base.txt" -merge-ours "ours.txt" -merge-theirs "theirs.txt" -merge-result "result.txt"
The result file initially contains the conflict markers. You can save partial resolutions: unresolved conflicts are written back with their original markers and labels. Saving preserves the detected encoding and line endings. Mark Resolved is available only after all conflicts are resolved; it also stages the result for an integrated Git merge. The three input files are read-only. With an existing Qt Creator instance, -client -block waits until the merge editor closes.
For Git, configure a custom merge tool:
git config mergetool.qtcreator.cmd 'qtcreator -client -block -merge-base "$BASE" -merge-ours "$LOCAL" -merge-theirs "$REMOTE" -merge-result "$MERGED"'
git config mergetool.qtcreator.trustExitCode false
git mergetool --tool=qtcreator
Git asks whether the merge succeeded after the editor closes. Closing the editor alone does not mark the file as resolved in Git.
Revert and apply changes
To revert the changes, right-click added text and then select Revert Chunk in the context menu.
To apply the changes, select removed text and then select Apply Chunk.
Reload files
If the files change outside Qt Creator, select
(Reload Diff) to compare them again and to show the results.
Paste changes for review
To send a chunk of changes to a code pasting service, select Send Chunk to CodePaster in the context menu.
Change colors
To change the default colors, go to Preferences > Text Editor > Font & Colors. Create your own color scheme and select new colors for the following items:
- Diff File Line sets the color of the line that shows the path and filename of the changed file.
- Diff Context Line sets the color of the line that shows the number of hidden lines between changed lines.
- Diff Source Line sets the color of lines that contain removed text.
- Diff Source Character sets the color that indicates removed characters.
- Diff Destination Line sets the color of lines that contain added text.
- Diff Destination Character sets the color that indicates added characters.
See also Paste and fetch code snippets.